<template>
  <div>
    <!-- 访问state -->
    <h2>{{ $store.state.num }}</h2>
    <!-- 调用mutations修改num -->
    <button @click="btnClick">点击调用mutations修改num</button>
    <!-- 调用actions修改num -->
    <button @click="btnClick2">点击调用actions修改num</button>
  </div>
</template>
<script>
export default {
  methods: {
    btnClick () {
      this.$store.commit('SETNUM', this.$store.state.num + 1)
    },
    btnClick2 () {
      const res = this.$store.dispatch('refreshNum', this.$store.state.num + 5)
      console.log('actions返回值', res)
    }
  }
}
</script>
<style></style>
